\hypertarget{class_r_t_o_s_1_1channel}{\section{R\-T\-O\-S\-:\-:channel$<$ T, S\-I\-Z\-E $>$ Class Template Reference}
\label{class_r_t_o_s_1_1channel}\index{R\-T\-O\-S\-::channel$<$ T, S\-I\-Z\-E $>$@{R\-T\-O\-S\-::channel$<$ T, S\-I\-Z\-E $>$}}
}


waitable data queue  




{\ttfamily \#include $<$p\-R\-T\-O\-S.\-h$>$}

Inheritance diagram for R\-T\-O\-S\-:\-:channel$<$ T, S\-I\-Z\-E $>$\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=4.000000cm]{class_r_t_o_s_1_1channel}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_r_t_o_s_1_1channel_a5580e7cd248a64985c8866c528cfebe6}{channel} (\hyperlink{class_r_t_o_s_1_1task}{task} $\ast$\hyperlink{class_r_t_o_s_1_1event_a1402687edb26c1d5d26e54dbda21919d}{t}, const char $\ast$name=\char`\"{}\char`\"{})
\begin{DoxyCompactList}\small\item\em constructor, specify stored type, number of entries, and name \end{DoxyCompactList}\item 
\hypertarget{class_r_t_o_s_1_1channel_a09e4d10e0336283eb9ae402df0a25dbc}{void \hyperlink{class_r_t_o_s_1_1channel_a09e4d10e0336283eb9ae402df0a25dbc}{write} (T item)}\label{class_r_t_o_s_1_1channel_a09e4d10e0336283eb9ae402df0a25dbc}

\begin{DoxyCompactList}\small\item\em write an item to the queue \end{DoxyCompactList}\item 
\hypertarget{class_r_t_o_s_1_1channel_a66da852f3e9ef72066e5f582f4c2f218}{T \hyperlink{class_r_t_o_s_1_1channel_a66da852f3e9ef72066e5f582f4c2f218}{read} (void)}\label{class_r_t_o_s_1_1channel_a66da852f3e9ef72066e5f582f4c2f218}

\begin{DoxyCompactList}\small\item\em read an item from the queue \end{DoxyCompactList}\item 
void \hyperlink{class_r_t_o_s_1_1channel_afd8cd81a91225ed144fc1ca20f3cd8f6}{clear} (void)
\begin{DoxyCompactList}\small\item\em clear the waitable \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Additional Inherited Members}


\subsection{Detailed Description}
\subsubsection*{template$<$class T, const int S\-I\-Z\-E$>$class R\-T\-O\-S\-::channel$<$ T, S\-I\-Z\-E $>$}

waitable data queue 

\begin{DoxyVerb}  The (communication) channel is a template class that stores a queue 
  of values. 
  Values can be written at the tail of the queue, up to the number of 
  entries for which the channel was created. 
  It is an error to write to a channel that is full. 
  Writes are not blocking. 
  Any task can write to a channel. 

  A channel is created for a particular task. 
  Only this owner task can read from the channel. 
  A read will block until an entry is available. 
  Reads are from the head of the queue.

  A channel is a waitable, so the task that owns the channel 
  can wait for the channel to be non-empty, after which a read 
  from a channel will be non-blocking (because the channel is 
  not empty). 
  After a wait() that returns the channel's event, the channel 
  will set itself again (because the wait did not cause it to 
  become empty). 
  Only a read that results in an empty queue will clear the channel. 

  The example below shows how writing to cout can be buffered 
  by first writing to a 2kB channel, and reading from that 
  channel at a maximum of one character per 2 MS. 
  The UART hardware in the LPC2148 chip buffers one character, 
  which at default baudrate (38k4) takes ~ 1 MS to write. 
  So by writing at a maximum rate of one character per 2 MS 
  no blocking will occur.

  @code 
\end{DoxyVerb}


class output\-\_\-class \-: public task \{ public\-: channel$<$ char, 2048 $>$ buffer( flags, \char`\"{}buffer\char`\"{} ); timer hartbeat( flags, \char`\"{}hartbeat\char`\"{} ); void main( void )\{ for(;;)\{ wait( buffer ); cout $<$$<$ buffer.\-get(); timer.\-set( 2 M\-S ); wait( timer ); \} \} \}

output\-\_\-class output;

void print( char $\ast$s )\{ while( $\ast$s != '\textbackslash{}0' )\{ output.\-buffer.\-write( $\ast$s++ ); \} \}

\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_r_t_o_s_1_1channel_a5580e7cd248a64985c8866c528cfebe6}{\index{R\-T\-O\-S\-::channel@{R\-T\-O\-S\-::channel}!channel@{channel}}
\index{channel@{channel}!RTOS::channel@{R\-T\-O\-S\-::channel}}
\subsubsection[{channel}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T, const int S\-I\-Z\-E$>$ {\bf R\-T\-O\-S\-::channel}$<$ T, S\-I\-Z\-E $>$\-::{\bf channel} (
\begin{DoxyParamCaption}
\item[{{\bf task} $\ast$}]{t, }
\item[{const char $\ast$}]{name = {\ttfamily \char`\"{}\char`\"{}}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{class_r_t_o_s_1_1channel_a5580e7cd248a64985c8866c528cfebe6}


constructor, specify stored type, number of entries, and name 

The template argument T must be a class that has a non-\/arguments constructor and supports assignment. 

\subsection{Member Function Documentation}
\hypertarget{class_r_t_o_s_1_1channel_afd8cd81a91225ed144fc1ca20f3cd8f6}{\index{R\-T\-O\-S\-::channel@{R\-T\-O\-S\-::channel}!clear@{clear}}
\index{clear@{clear}!RTOS::channel@{R\-T\-O\-S\-::channel}}
\subsubsection[{clear}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T, const int S\-I\-Z\-E$>$ void {\bf R\-T\-O\-S\-::channel}$<$ T, S\-I\-Z\-E $>$\-::clear (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [virtual]}}}\label{class_r_t_o_s_1_1channel_afd8cd81a91225ed144fc1ca20f3cd8f6}


clear the waitable 

This is automatically doen when the waitable causes a \hyperlink{class_r_t_o_s_1_1task_a6fc603d0f1c8a94813586d3dfd123fcc}{task\-::wait()} call to return it. 

Reimplemented from \hyperlink{class_r_t_o_s_1_1waitable_a44ac71980592721bc03e076acc7e8c67}{R\-T\-O\-S\-::waitable}.



The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
p\-R\-T\-O\-S.\-h\end{DoxyCompactItemize}
